R-Tek Scratchpad Version 1.00 TSPadDatad TPictured TCommentTextd TLogFontd Times New Roman densed BT Matrix Functions nnnnnnnnnnnnnnnn] TCommentTextd The matrix operators were described in the example file "basics". This file describes the built-in matrix functions. Context sensitive help is available for built-in functions with Ctrl+F1 when the caret is positioned on a function name within an expression. nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] TExpressiond imat(3) TExpressiond zmat(2,3) TExpressiond onesvec(4) TExpressiond V:rmat(6,1,5) TExpressiond A:rmat(6,6,-5) TExpressiond submat(A,2,3,4,5) TExpressiond subvec(V,2,4) TCommentTextd rmatex0, rmatex01, rmatexint, rmatexs, rmatexs0, rmatexs01, rmatexsint These rmatex? functions exists just like the rndex? numeric functions to exclude specific matrix element values. rmatexs? type functions exclude singular square matrices. nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] TCommentTextd Ctrl+m produces a display matrix, whose values you fill in yourself. You can change the size of a display matrix by Alt+m on an active display matrix element. You can also change the matrix element alignment by changing the expression's numeric format, either globally or individually. nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnn] TCommentTextd A common way of producing an initialized matrix is to create a zmat and then calculate the matrix elements in a matloop. Use the matrix subscript grouping chars [ and ] to identify a particular matrix element. nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnn] TExpressiond m:zmat(3,4) TMatLoopd TExpressiond m[i,j] TCommentTextd The matloop is equivalent to two whiles and take on values that correspond to all the matrix elements. i and j are commonly used as subscript identifiers but you are free to choose any names you wish. nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnn] TExpressiond m[i,j]:10*i+j TEndMatLoopd TExpressiond THardPageBreakd TExpressiond randomize(39) TCommentTextd seed the random number generator to produce the same sequence of random numbers each time you run the program.n nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] TCommentTextd exclude singular because we want the inverse later2 nnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnn] TExpressiond m:rmatexs(3,3,4) TExpressiond sum(m) TCommentTextd sum of elements nnnnnnnnnnnnnnn] TExpressiond mean(m) TExpressiond max(m) TCommentTextd maximum nnnnnnn] TExpressiond var(m) TCommentTextd variance nnnnnnnn] TExpressiond min(m) TCommentTextd minimum nnnnnnn] TExpressiond stddev(m) TCommentTextd standard deviation nnnnnnnnnnnnnnnnnn] TExpressiond tr(m) TCommentTextd trace - the sum of the diagonal elements of m 0+3+05 nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnn] TCommentTextd use the column extraction grouping chars Ctrl+[ and Ctrl+]: nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] TExpressiond TCommentTextd use the row extraction grouping chars Alt+[ and Alt+]5 nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] TExpressiond TExpressiond reverse(m) TCommentTextd reverses the order of the rows of m# nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] TCommentTextd reverses the order of the elements of a vector. nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] TExpressiond reverse(v) TCommentTextd sorts the elements of a vector nnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] TExpressiond sort(v) TCommentTextd sorts the columns of m based on the values in the nth row9 nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] TExpressiond csort(m,1) TCommentTextd sorts the rows of m based on the values in the nth column9 nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] TExpressiond rsort(m,2) THardPageBreakd TExpressiond TCommentTextd refresh our memory of m nnnnnnnnnnnnnnnnnnnnnnn] TExpressiond minor(m,3,1) TCommentTextd the minor of m is the determinant of the submatrix formed by eliminating the ith row and the jth column of ml nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] TExpressiond minor(m,1,3) TExpressiond adj(m) TCommentTextd the adjoint matrix is one whose elements are the transposed cofactors of its original elements, ie the signed minors of order n-1. nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] TCommentTextd The adjoint matrix is related to the matrix inverse by Cramers rule.D nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] TExpressiond TExpressiond 1/{m}*adj(m) TExpressiond TCommentTextd scalar multiplication - note that division by a scalar is not allowed (although you can get away with multiplying by a fraction) nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnn] TCommentTextd The rank of a matrix is the number of linearly independent rows of m, which must be less than or equal to the number of columns of m. If the rank of a square matrix m is less than the number of rows, the matrix is singular (does not possess an inverse). The determinant of such a matrix is zero.) nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] TCommentTextd does possess an inverse nnnnnnnnnnnnnnnnnnnnnnn] TExpressiond rank(m) TExpressiond s:M000300031@2@3@2@1@5@2@4@6@ TCommentTextd does not possess an inverse nnnnnnnnnnnnnnnnnnnnnnnnnnn] TExpressiond rank(s) TExpressiond echelon(s) TCommentTextd echelon(m) converts m to echelon form through elementary row operations. If the matrix has an inverse, the echelon form of the matrix is the identity matrix. The number of non-zero rows of the echelon form is the rank of m. nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] THardPageBreakd TCommentTextd echtrans(m) is the matrix product of all the elementary row operations that convert m to echelon form. If the matrix has an inverse, echtrans(m) produces the inverse. nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] TExpressiond echtrans(s) TExpressiond TExpressiond b:M000300012@-1@3@ TCommentTextd The simple way of solving a matrix equation of the form A * x=b is:C nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] TCommentTextd which is verified by: nnnnnnnnnnnnnnnnnnnnn] TExpressiond x:A^-1*b TExpressiond TCommentTextd but for the case where the matrix is singular, the inverse does not exist. The system of equations may have either no solution, in which case we say the equations are inconsistant, or the equations may have an infinite number of related solutions. nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnn] TCommentTextd Consider A, an m x n matrix of rank r and that A * x = b.9 nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn] TCommentTextd If b is all zeros, this is called the homogeneous case. In this case, if r = n, there is the trivial solution (where x is all zeros) only. If r